package com.isak.likou.likoudemo.utils;

/**
 * 随机字符串生成（小写）
 */
public class RandomString {

    public static final String lower = "abcdefghijklmnopqrstuvwxyz";

    /**
     * 获取指定长度的字符串
     * @param length
     * @return
     */
    public static String getLowerString(int length){
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < length; i++) {
            sb.append(lower.charAt(((int) (Math.random() * 26))));
        }
        return sb.toString();
    }


    /**
     * 获取随机长度（1-100）字符串
     * @return
     */
    public static String getLowerString(){
        int length = (int) (Math.random() * 100) +1;
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < length; i++) {
            sb.append(lower.charAt(((int) (Math.random() * 26))));
        }
        return sb.toString();
    }

}
